<!DOCTYPE HTML>
<html>
<!--_meta 作为公共模版分离出去-->
{include file="common/_meta"}
<!--/meta 作为公共模版分离出去-->

<body>
<!--_header 作为公共模版分离出去-->
{include file="common/_header"}
<!--/_header 作为公共模版分离出去-->
<!--_menu 作为公共模版分离出去-->
{include file="common/_menu"}
<!--/_menu 作为公共模版分离出去-->

<section class="Hui-article-box">
        {include file="common/_nav"}
<div class="Hui-article">
<article class="cl pd-20">
        <form action="" method="post" class="form form-horizontal" id="form-article-edit">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>&nbsp;&nbsp;&nbsp;栏&nbsp;&nbsp;&nbsp;目&nbsp;：</label>
                <div class="formControls col-xs-8 col-sm-2"> <span class="select-box">
                    <select class="select" id="sel_Sub" name="cid">
                        <option value="0">--请选择栏目--</option>
                        {foreach $category_data as $value}
                        <option value="{$value.id}"  {eq name="data.cate_id" value="$value.id"}selected{/eq} > {$value.category_name}</option>
                            {notempty name="value._child"}
                            {foreach  $value._child  as $val}
                            <option value="{$val.id}" {eq name="data.cate_id" value="$val.id"}selected{/eq}>&nbsp;├─ {$val.category_name}</option>
                                {notempty name="val._child"}
                                {foreach  $val._child  as $v}
                                <option value="{$v.id}" {eq name="data.cate_id" value="$v.id"}selected{/eq}>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── {$v.category_name}</option>
                                {/foreach}
                                {/notempty}
                            {/foreach}
                            {/notempty}
                        {/foreach}
                    </select></span> 
                    <span class="c-red">(不选则视为无栏目文章)</span>
                </div>

                <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>文章模板：</label>
                <div class="formControls col-xs-8 col-sm-2"> <span class="select-box">
                    <select class="select" id="sel_Sub" name="template" >
                        <option value="0">--请选择模板--</option>
                        <!-- {foreach $data as $val}
                        <option value="{$val.id}">{$val.category_name}</option>
                            {notempty name="val.child"}
                            {foreach  $val.child  as $v}
                            <option value="{$v.id}">&nbsp;&nbsp;├ {$v.category_name}</option>
                            {/foreach}
                            {/notempty}
                        {/foreach} -->
                    </select></span>
                    <span class="c-red">(不选则为默认栏目模板)</span>
                </div>
                <div class="col-3"> </div>
            </div>
            <!-- 文章标题 -->
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>文章标题：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input type="text" class="input-text" value="{$data.title} " id="title" name="title">
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">&nbsp;作&nbsp;&nbsp;者&nbsp;：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" class="input-text" value="{$data.writer}"  id="writer" name="writer">
                </div>
                <label class="form-label col-xs-4 col-sm-1">文章来源：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" class="input-text" value="{$data.source}" id="source" name="source">
                </div>

                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">&nbsp;关键字&nbsp;：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input type="text" class="input-text" value="{$artcile_content.keywords}"  id="keywords" name="keywords">
                </div><span class="c-red">*用英文半角逗号(,)隔开多个关键字</span>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">简述：</label>
                <div class="formControls col-xs-8 col-sm-5">
                    <textarea name="description" cols="" rows="" class="textarea"  datatype="*10-100" dragonfly="true" nullmsg="备注不能为空！" onKeyUp="textarealength(this,200)">{$artcile_content.description}</textarea>
                    <p class="textarea-numberbar"><em class="textarea-length">0</em>/200</p>
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>是否开启留言：</label>
                <div class="formControls col-xs-8 col-sm-2 skin-minimal">
                    <div class="radio-box">
                        <input name="islev_msg" type="radio" id="islev-1" value="1" {eq name="data.islev_msg" value="1"}checked{/eq} >
                        <label for="sex-1">启用</label>
                    </div>
                    <div class="radio-box">
                        <input name="islev_msg" type="radio" id="islev-2" value="0" {eq name="data.islev_msg" value="0"}checked{/eq}>
                        <label for="sex-2">不启用</label>
                    </div>
                </div> 
                <label class="form-label col-xs-4 col-sm-1">排序</label>
                <div class="formControls col-xs-8 col-sm-1">
                    <input type="text" class="input-text" value="{$data.sort}"  name="sort"  style="width:60px;">
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>缩略图：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input type="text" class="input-text" value="{$data.thumb}" id="thumb"  name="thumb" >
                </div>
                <div class="formControls col-xs-8 col-sm-1">
                <a href="javascript:;" class="btn btn-primary radius" onClick="addthumb()" ><i class="Hui-iconfont">&#xe600;</i>添加缩略图</a>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>文章内容：</label>
                <div class="formControls col-xs-8 col-sm-8"> 
                    <script id="editor" type="text/plain" style="width:100%;height:400px;">{$artcile_content.body}</script> 
                </div>
                <div class="col-3"> </div>
            </div>
            
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                    <button onClick="article_save_submit();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存并提交审核</button>
                    <button onClick="article_save();" class="btn btn-secondary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存草稿</button>
                    <button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
                </div>
            </div>
        </form>
    </article>
</div>
</section>

<!--_footer 作为公共模版分离出去-->
{include file="common/_footer" /}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本--> 
<!-- <script type="text/javascript" src="/static/lib/webuploader/0.1.5/webuploader.min.js"></script>  -->
<script type="text/javascript" src="/static/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="/static/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="/static/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>

<script type="text/javascript">

$(function(){
//实例化编辑器   
	var ue = UE.getEditor('editor');

//提交表单
    $("#form-article-edit").submit(function(){
        var note = $("#description").val();
    
        if(!$("#title").val()){
            layer.msg('标题不能为空!',{icon:5,time:1000});
            return false;
        }
        
        if(getblen(note)>200){
            layer.msg('备注过长',{icon:5,time:1000});
            return false;
        }
    })  
});

function textarealength(obj,toplength){
    var note =$(obj).val();
    var blen = getblen(note);

    if(blen<=toplength){
        $(".textarea-length").html(blen);
    }else{
        $(".textarea-length").css('color','red');
        $(".textarea-length").html(blen);
    }
}
//获取textarea字符长度，中文单字2字符，英文1字符
function getblen(str){
    var l = str.length;
    var blen = 0;

    for(i=0; i<l; i++) {
        if ((str.charCodeAt(i) & 0xff00) != 0) {
            blen ++;
        }
            blen ++;
    }

    return blen;
}

//添加缩略图
function addthumb(){
    layer.open({
		type: 2,
		area: ['700px', '500px'],
		fix: false, //不固定
		maxmin: true,
		shade:0.4,
		title: '添加缩略图',
		content: '{:url("filebrowser/select_thumb")}'
	});
}

</script>
<!--请在上方写此页面业务相关的脚本--> 

</body>
</html>